import { GetUserList } from "@/api/userList";

const state = {
  userData: {},
};

const mutations = {
  SET_USERDATA: (state, userData) => {
    state.userData = userData;
  },
};

const actions = {
  async getUserData({ commit }, pageList) {
    try {
      const result = await GetUserList(
        pageList.page,
        pageList.limit,
        pageList.searchUsername
      );
      commit("SET_USERDATA", result.data);
      return "ok";
    } catch (error) {
      return Promise.reject(new Error("获取失败"));
    }
  },
};

const getters = {};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
